/*
 * 20.10.2008 - Albert Weinert - erstellt.
 * 
 */
using System;
using System.Collections.Generic;
using IssueExplorer.Items;
using IssueExplorer.Presenters;
using IssueExplorer.Providers.TeamFoundationServer.Managers;
using IssueExplorer.Providers.TeamFoundationServer.Properties;
using IssueExplorer.Providers.TeamFoundationServer.Views;

namespace IssueExplorer.Providers.TeamFoundationServer.Presenters
{
    public class WorkItemExplorerPresenter : PresenterWithView<IWorkItemExplorerView>
    {
        private readonly IWorkItemManager manager;

        public WorkItemExplorerPresenter(IWorkItemExplorerView view, IWorkItemManager manager) : base(view)
        {
            this.manager = manager;
        }

        protected override void OnInit()
        {
            base.OnInit();
            InitializeView();
        }

        private void InitializeView()
        {
            View.ListOfProjects = GetListOfProjects();
            View.ListOfSubProjects = GetListOfSubProjects();
            View.ListOfAssigned = GetListOfAssigned();
            View.ListOfStatus = GetListOfPossibleStatus();
            View.ListOfWorkItems = new List<TrackingItem>();
        }

        private List<string> GetListOfPossibleStatus()
        {
            var possibleStatus = new List<string> {SR.please_choose};
            possibleStatus.AddList(manager.GetPossibleStatus());
            return possibleStatus;
        }

        private List<string> GetListOfAssigned()
        {
            var assigned = new List<string> {SR.please_choose};
            assigned.AddList(manager.GetAssigned());
            return assigned;
        }

        private IList<string> GetListOfSubProjects()
        {
            var subProjects = new List<string> {SR.please_choose};
          //  subProjects.AddList(manager.GetSubProjects(View.SelectedProject));
            return subProjects;
        }

        private IList<string> GetListOfProjects()
        {
            var projects = new List<string> {SR.please_choose};
         //   projects.AddList(manager.GetAllProjects());
            return projects;
        }

        protected override void AttachViewEventHandler()
        {
            base.AttachViewEventHandler();
            View.FilterWorkItems += FilterWorkItems;
        }

        private void FilterWorkItems(object sender, EventArgs e)
        {
        }
    }
}